package interfaces.options;

import fileHandling.language.Lang;
import interfaces.GUISource;
import interfaces.inputValidation.InputCheckContainer;
import interfaces.inputValidation.InputChecker;

import org.fenggui.TextEditor;

public class TextEditorOptionWidget extends OptionWidget {
	
	private TextEditor textEditor;
	private InputCheckContainer container;
	
	public TextEditorOptionWidget(String initValue, Lang description, InputChecker... checkers) {
		super(description, initValue);
		textEditor = new TextEditor();
		GUISource.setTheme(textEditor);
		GUISource.setFont(textEditor, GUISource.middleFont);
		textEditor.setText(initValue);
		addWidget(textEditor);
		
		container = new InputCheckContainer(checkers);
	}
	
	@Override
	public String getValue() { return textEditor.getText().substring(0, textEditor.getText().length() - 1); }

	@Override
	public void setToHigh() {}
	
	@Override
	public void setToMedium() {}
	
	@Override
	public void setToLow() {}
	
	@Override
	public void changeValue(String value) { textEditor.setText(value); }
	
	public String checkInput() {
		return container.check(getValue());
	}
}